﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace GMS.Client.Core
{
    /// <summary>
    /// 选项卡
    /// </summary>
    public class TabControl : CustomControl
    {
        public TabControl(IntPtr parentHandle, string className, string titleName, CustomControlNameType customControlNameType = CustomControlNameType.Default) :
            base(parentHandle, className, titleName, customControlNameType)
        { }

        public TabControl(IntPtr handle, CustomControlNameType customControlNameType = CustomControlNameType.Default)
            : base(handle, customControlNameType)
        { }

        /// <summary>
        /// 初始化所有选项页
        /// </summary>
        public void InitTabPages()
        {
            var pages = Win32API.SendMessage(Handle, (int)WindowsMessageType.TCM_GETITEMCOUNT, 0, 0);
            for (var i = 0; i < pages; i++)
            {
                Win32API.SendMessage(Handle, (int)WindowsMessageType.TCM_SETCURFOCUS, i, 0);
                Win32API.SendMessage(Handle, (int)WindowsMessageType.TCM_SETCURSEL, i, 0);
            }
            Win32API.SendMessage(Handle, (int)WindowsMessageType.TCM_SETCURFOCUS, 0, 0);
            Win32API.SendMessage(Handle, (int)WindowsMessageType.TCM_SETCURSEL, 0, 0);
        }
    }
}
